package com.my.design.structural.proxy.JdkProxy;

import com.my.design.structural.proxy.staticProxy.*;
import com.my.design.structural.proxy.staticProxy.impl.*;

import java.lang.reflect.*;

/**
 * @author 代廷波
 * @className: Test
 * @description:
 * @create 2018/12/21 0021-11:18
 **/
public class Test {
    public static void main(String[] args) throws Exception {
        CarImpl car = new CarImpl();
        InvocationHandler invocationHandler = new JdkProyx(car);
        Class clazz = car.getClass();

        /**
         * loader:类加载器
         * interfaces 实现接口
         * h: InvcationHandler 代理类
         */

       ICar carImpl = (ICar)Proxy.newProxyInstance(clazz.getClassLoader(), clazz.getInterfaces(), invocationHandler);

        carImpl.move("奔驰",300);
/*
        ICar m = (ICar)MyProxy.newProxyInstance(clazz, new JdkProyx(new CarImpl()));
       m.move("布加迪",300);*/
    }
}
